#ifndef GY_GRAPHICSPOLYGONITEM_H
#define GY_GRAPHICSPOLYGONITEM_H

#include "Graphics/BasicGraphics/GY_BasicsGraphicsObject.h"
#include "GY_ControlLibrary_global.h"
#include <QGraphicsPathItem>
#include <QObject>
#include <QPolygonF>
#include <QPointF>
#include <QVector>
#include <QPainter>
class GY_CONTROLLIBRARY_EXPORT GY_GraphicsPolygonItem :public GY_BasicsGraphicsObject
{
    Q_OBJECT
public:
    explicit Q_INVOKABLE GY_GraphicsPolygonItem(const QString &guid,QGraphicsItem *parent = nullptr);
    ~GY_GraphicsPolygonItem(){
        m_PropertyInfoMap.clear();
    };
public:
    int count = 0;
    //添加属性信息Map
    void initializationPropertyInfo();
    //绘制
    bool drawPolygon();
    //绘制光晕
    void drawHalo();
    //批量添加点
    bool addPointInBulk(quint32 count);
    //批量删除点
    bool deletePointInBulk(quint32 count);
    // QGraphicsItem interface

//    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
public:
    //设置PtsArray的Capacityo属性
    bool setPtsArrayCapacity(const QString &name, const QVariant &value);
    //设置PtsArray的Size属性
    bool setPtsArraySize(const QString &name, const QVariant &value);
    //更新多边形的可编辑point的值
    bool updatePoint(const QString &name, const QVariant &value);
    //添加点，并添加属性信息
    bool addPoint(const QString &name, const QVariant &value);
    //选中点之后添加
    bool addPointAfter(const QString &name, const QVariant &value);
    //选中点之前添加
    bool addPointBefore(const QString &name, const QVariant &value);
    //删除点、删除属性信息 并添加删除点信息
    bool deletePoint(const QString &name, const QVariant &value);
    bool setHaloLineWidth(const QString &name, const QVariant &value);
    //设置光晕的颜色
    bool setHaloColor(const QString &name, const QVariant &value);
    //设置是否有光晕
    bool setIsHaloed(const QString &name, const QVariant &value);
public:
    /**
     * @brief The PointInfo struct
     * 点的信息结构体
     */
    struct PointInfo
    {
        //!属性名称
        QString pointName;
        //!属性值
        QPointF pointValue;
        PointInfo()
        {
            pointName = "";
            pointValue = QPointF();
        }
        PointInfo(QString name, QPointF point)
        {
            pointName = name;
            pointValue = point;
        }
    };
    //构图容器
    QPainterPath m_pPath;
    //存储删除点的信息(限制大小为64)
    QMap<quint32, PointInfo> m_pointDeleteInfoMap;
    //point数量(size)
    quint32 m_pointSize;
    //Capacityo的值
    quint32 m_capacitySize;
    //是否抗锯齿
    bool m_isAntialiased;
};

#endif // GY_GRAPHICSPOLYGONITEM_H
